package org.springsource.examples.crm.services.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.*;
import org.springframework.jdbc.datasource.SimpleDriverDataSource;
import javax.sql.DataSource;

@Configuration
public class CrmConfiguration {
	@Value("${dataSource.driverClassName}")
	private String driverName;

	@Value("${dataSource.url}")
	private String url;

	@Value("${dataSource.user}")
	private String user;

	@Value("${dataSource.password}")
	private String password;

	@Bean
	public DataSource dataSource() {
		SimpleDriverDataSource simpleDriverDataSource = new SimpleDriverDataSource();
		simpleDriverDataSource.setPassword(this.password);
		simpleDriverDataSource.setUrl(this.url);
		simpleDriverDataSource.setUsername(this.user);
		simpleDriverDataSource.setDriverClass(oracle.jdbc.OracleDriver.class);
		return simpleDriverDataSource;
	}
}